/*
 Interpreter routines for the Malio language.

 For details on specifications of the Malio language, please see:
 https://notabug.org/Malio

 Copyright 2015 - Malio dev team

  This file is part of malio-cpp: an interpreter for the Malio 
  language written in C++

  malio-cpp is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  malio-cpp is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

 */

#include <iostream>
#include <string>
#include <fstream>
#include "parser.h"
#include "builtins.h"

const std::string MALIO_CPP_VERSION = "0.3-alpha";

inline void show_version()
{
    std::cout << "Malio Language Interpreter version " << MALIO_CPP_VERSION
        << std::endl;
}

int main(int argc, char * argv[])
{
    if (argc == 1) {
        std::cout << "Missing filenames. See '-h' for more information.\n";
        return 1;
    }
    else if (argv[1][1] == 'h') {
        std::cout << "interpreter for the malio language.\n";
        std::cout << "USAGE: " << argv[0] << "[-hv] FILE\n";
        std::cout << "Where: \n";
        std::cout << "-h:\tDisplays this help message\n";
        std::cout << "-v:\tDisplays the interpreter version information\n";
    }
    else if (argv[1][1] == 'v') {
        show_version();
    }
    else if (argv[1][0] == '-') {
        std::cout << "Unknown options. See '-h' for more information.\n";
        return 2;
    }
    else {
        return malio::read(argv[1]);
    }
    return 0;
}
